package com.isunland.managesystem.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.entity.ReplyList;
import java.util.List;

public class MessageReplyAdapter extends ArrayAdapter<ReplyList> {

  /**
   * ViewHolder class for layout.<br />
   * <br />
   * Auto-created on 2015-07-20 17:19:40 by Android Layout Finder
   * (http://www.buzzingandroid.com/tools/android-layout-finder)
   */
  private static class ViewHolder {
    public final LinearLayout rootView;
    public final TextView tvSendPeopleAdapterMessageReply;
    public final TextView tvReplyTimeAdapterMessageReply;
    public final TextView tvContentAdapterMessageReply;

    private ViewHolder(LinearLayout rootView, TextView tvSendPeopleAdapterMessageReply,
        TextView tvReplyTimeAdapterMessageReply, TextView tvContentAdapterMessageReply) {
      this.rootView = rootView;
      this.tvSendPeopleAdapterMessageReply = tvSendPeopleAdapterMessageReply;
      this.tvReplyTimeAdapterMessageReply = tvReplyTimeAdapterMessageReply;
      this.tvContentAdapterMessageReply = tvContentAdapterMessageReply;
    }

    public static ViewHolder create(LinearLayout rootView) {
      TextView tvSendPeopleAdapterMessageReply =
          (TextView) rootView.findViewById(R.id.tv_sendPeople_adapterMessageReply);
      TextView tvReplyTimeAdapterMessageReply =
          (TextView) rootView.findViewById(R.id.tv_replyTime_adapterMessageReply);
      TextView tvContentAdapterMessageReply =
          (TextView) rootView.findViewById(R.id.tv_content_adapterMessageReply);
      return new ViewHolder(rootView, tvSendPeopleAdapterMessageReply,
          tvReplyTimeAdapterMessageReply, tvContentAdapterMessageReply);
    }
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder vh;
    if (convertView == null) {
      View view = mInflater.inflate(R.layout.adapter_reply_list, parent, false);
      vh = ViewHolder.create((LinearLayout) view);
      view.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }

    ReplyList item = getItem(position);

    //Bind your data to the views here
    vh.tvReplyTimeAdapterMessageReply.setText(
        mContext.getString(R.string.replyTime, item.getReplyTime()));
    vh.tvSendPeopleAdapterMessageReply.setText(
        mContext.getString(R.string.sendPeople, item.getReply()));
    vh.tvContentAdapterMessageReply.setText(item.getContent());
    return vh.rootView;
  }

  private LayoutInflater mInflater;
  private Context mContext;

  // Constructors
  public MessageReplyAdapter(Context context, List<ReplyList> objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
    this.mContext = context;
  }

  public MessageReplyAdapter(Context context, ReplyList[] objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
    this.mContext = context;
  }
}


 
